const { ccclass, property } = cc._decorator;

@ccclass
export default class ImageUtil extends cc.Component {
    static getTrim(e, t, a) {
        let o, i, r, n = 0, l = 0, s = 4 * t;
        e: for (n = 0; n < t; n++) {
            for (l = 0; l < a; l++) {
                if (0 !== e[s * l + 4 * n + 3]) {
                    break e;
                }
            }
        }
        o = n;
        e: for (n = t - 1; n >= 0; n--) {
            for (l = 0; l < a; l++) {
                if (0 !== e[s * l + 4 * n + 3]) {
                    break e;
                }
            }
        }
        i = n + 1;
        e: for (n = 0; n < a; n++) {
            for (l = 0; l < t; l++) {
                if (0 !== e[s * n + 4 * l + 3]) {
                    break e;
                }
            }
        }
        r = n;
        e: for (n = a - 1; n >= 0; n--) {
            for (l = 0; l < t; l++) {
                if (0 !== e[s * n + 4 * l + 3]) {
                    break e;
                }
            }
        }
        return {
            minX: o,
            maxX: i,
            minY: r,
            maxY: n + 1
        };
    }
}